package LeetCode;

import java.util.List;

public class LC120 {
    public int minimumTotal(List<List<Integer>> triangle) {
        int[][] ans = new int[triangle.size()][triangle.get(0).size()];
        for (int i = triangle.size()-2; i >=0; i--) {
            for (int j = 0; j < triangle.get(i).size(); j++) {
                ans[i][j] =Math.min(ans[i+1][j],ans[i+1][j+1]) + triangle.get(i).get(j);
            }
        }
        return ans[triangle.size()-1][triangle.get(0).size()-1];
    }


}
